<template name="AdminLayout">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{{#if AdminConfig}}
 {{#if isInRole 'admin'}}
  <div class="admin-layout">
    <div class="skin-{{adminGetSkin}}">
      {{> AdminHeader}}
      <div class="wrapper row-offcanvas row-offcanvas-left">
        {{> AdminSidebar }}
        <aside class="right-side">
          <section class="content-header">
            <h1>
              {{$.Session.get 'admin_title'}}
              <small>{{$.Session.get 'admin_subtitle'}}</small>
            </h1>
            <div class="header-right">
              <ol class="breadcrumb">
                <li><a href="/admin/">{{_ 'dashboard'}}</a></li>
                {{#if $.Session.get 'admin_collection'}}
                <li><a href="/admin/{{admin_collection}}/">{{adminCollectionLabel admin_collection_name}}</a></li>
                {{/if}}

                {{#if $.Session.equals 'admin_collection_page' 'new'}}
                <li><a href="/admin/{{admin_collection}}/new">{{_ 'new'}}</a></li>
                {{/if}}

                {{#if $.Session.equals 'admin_collection_page' 'edit'}}
                <li><a href="/admin/{{admin_collection}}/edit">{{_ 'edit'}}</a></li>
                {{/if}}


              </ol>
              {{#if $.Session.get 'admin_collection_name'}}
              <a href="{{pathFor 'adminDashboardNew' collection=admin_collection_name}}" class="new-document btn btn-primary btn-sm"><i class="fa fa-plus" style="vertical-align:text-bottom;"></i> {{_ 'addOne'}}</a>
              {{/if}}
            </div>
          </section>
          <section class="content">
            {{> yield }}
          </section>
        </aside>

      </div>
    </div>
  </div>
  {{> AdminDeleteModal }}
  {{else}}
  {{> NotAdmin}}
  {{/if}}
  {{else}}
  {{> NoConfig}}
  {{/if}}
</template>

<template name="AdminDeleteModal">
  <div class="modal fade" id="admin-delete-modal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
          <h4 class="modal-title">{{_ "deleteModal.confirm"}}</h4>
        </div>
        <div class="modal-body">
          <p>{{_ "deleteModal.question"}}</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">{{_ "deleteModal.close"}}</button>
          <button type="button" id="confirm-delete" class="btn btn-danger">{{_ "deleteModal.delete"}}</button>
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div><!-- /.modal -->
</template>

<template name="NotAdmin">
<div class="container">
<div class="row">
  <div class="col-md-4 col-md-offset-4">
    <p class="alert alert-info" style="margin-top:100px;">
      {{_ "notAdmin"}}
    </p>
    <form class="form-signin">
      <label for="email" class="sr-only">{{_ "user.email"}}</label>
      <input type="text" id="email" class="form-control" placeholder="{{_ 'user.email'}}" required="" autofocus="">
      <label for="password" class="sr-only">{{_ "user.pwd"}}</label>
      <input type="password" id="password" class="form-control" placeholder="{{_ 'user.pwd'}}" required="">
      <button class="btn btn-lg btn-primary btn-block" type="submit">{{_ "user.signIn"}}</button>
    </form>
  </div>
</div>
</div>
</template>

<template name="NoConfig">
  <p class="alert alert-info">
    You need to define an AdminConfig object to use the admin dashboard.
    <br/>
    A basic config to manage the 'Posts' and 'Comments' collection would look like this:
    <br/>
    <code>
    AdminConfig = {
    <br/>
      adminEmails: ['  ben@code2create.com'],
    <br/>
      collections:
    <br/>
        {
    <br/>
          Posts: {},
    <br/>
          Comments: {}
    <br/>
        }
    <br/>
    }
    </code>
  </p>
</template>
